<template>

  <el-dialog title="设置黑名单企业" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="800px">
    <div class="title-tips">精准匹配企微号“@”后的企业名称，检测到该企业的企微号入群，在群里发言后自动加入黑名单</div>
    <div class="content-big">
      <div class="content-right">
        <div class="table-head">
          <div class="table-left"><el-button type="primary" size="small" plain>添加企业</el-button></div>
          <div class="table-right">
            <el-input v-model="queryParams.userName1" placeholder="搜索企微号" clearable @keyup.enter.native="handleQuery" suffix-icon="el-icon-search"/>
            <el-button icon="el-icon-search" size="small"></el-button>
          </div>
        </div>
        <el-table
          :data="tableDataList"
          ref="companylabelList"
        >
          <el-table-column
            :label="item.label"
            align="center"
            v-for="(item, index) in tableColumns"
            :key="index"
            :prop="item.key"
            :min-width="item.minWidth ? item.minWidth : ``"
            :fixed="item.fixed ? item.fixed : false"
            :show-overflow-tooltip="true"
          >
            <!--用于表格自定义-->
            <template slot-scope="scope">
              <div v-if="item.key=='name'">
                <div class="userInfo">
                  <img src="../../../assets/images/profile.jpg"/>
                  <div class="user-big">
                    <div class="name">锐行科技</div>
                  </div>
                </div>

              </div>
              <div v-else-if="item.key=='status'">
                <el-switch v-model="scope.row[item.key]" @change="handleStatusChange(scope.row)"
                ></el-switch>
              </div>
              <div v-else style="text-align: center">{{ scope.row[item.key] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="created_at"
            label="操作"
            width="150"
            fixed="right"
            align="center"
          >
            <template slot-scope="scope">
              <div class="group-btn">
                <el-button type="text" slot="reference" @click="handleApplication(scope.row)">删除</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>


    <div class="footer-btn" slot="footer">
      <el-button  @click="handleCloseDialog">取消</el-button>
      <el-button type="primary">提交</el-button>
    </div>
  </el-dialog>
</template>

<script>


import {listUser} from "@/api/system/user";
import MultipleSelect from "@/views/components/multipleSelect.vue";

export default {
  name: 'selectLabelPage',
  components: {
    MultipleSelect
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName1: null,
        userName2: null,
        userName3: null,
        userName4: null,
        userName5: null,
        userName6: null,
        userName7: null,
        userName8: null,
        userName9: null,
        userName10: null,
        userName11: null,
        userName12: null,
        userName13: null,
        userName14: null,
      },
      callList: [
        //称呼
        {id: 1, name: "有"},
        {id: 2, name: "无"},
      ],
      tableColumns: [
        {key: 'name', label: `企业名称`, visible: true, minWidth: 150, fixed: true},
        {key: 'name2', label: `加入时间`, visible: true, minWidth: 150, fixed: true},
      ],
      tableDataList:[],
      lableOpt: [
        {value: 1, label: '客户等级', children: [
            {value: 3, label: '核心',},
            {value: 4, label: '重要',},
            {value: 5, label: '一般',}
          ]
        },
        {value: 2, label: '客户等级2', children: [
            {value: 6, label: '可爱',},
            {value: 7, label: '知性',},
            {value: 8, label: '性感',}
          ]}
      ],
      sexList: [
        //性别
        {id: 1, name: "男"},
        {id: 2, name: "女"},
      ],
      total: 8, // 表格的总条数
      multipleSelection: [],//表格多选
      showSelectSmartTags: false,//智能标签
      tableHeight: 600,
      dateRange1: [],
    }
  },
  created() {
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        name2: '18207418337',
        status:'是',
      }
      this.tableDataList.push(obj);
    }
  },
  mounted() {
  },
  watch: {},
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(val) {
      this.multipleSelection = [];
      if (val && val.length > 0) {
        val.forEach((item) => {
          this.multipleSelection.push(item.id);
        })
      }
    },
    handleApplication(row){
      //应用
    },
    handleStatusChange(row) {
      // console.log('状态', row.status);
      // let text = row.status == false ? "暂停" : "启用";
      // this.$modal.confirm(`确认要${text}广告计划（${row.name}）吗？`).then(function () {
      //   if (row.status == false) {
      //     return reqSubmittedStatusStopAlone(row.id);
      //   } else {
      //     return reqSubmittedStatusOpenAlone(row.id);
      //   }
      // }).then(() => {
      //   this.$modal.msgSuccess(text + "成功");
      //   this.getList();
      // }).catch(function () {
      //   row.status = row.status == 1 ? false : true;
      // });
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    },
  }
}
</script>

<style scoped lang="scss">
.number {
  position: absolute;
  left: 10px;
  top: 0px;
  font-size: 14px;
  span {
    color: rgba(0, 0, 0, .65);
    color: rgb(240, 139, 0);
  }
  .el-button {
    color: #3370ff;
    border: none;
  }
}
.footer-btn {
  position: relative;


}
.userInfo {
  border-radius: 4px;
  margin: 8px 0;
  cursor: pointer;
  position: relative;
  padding-left: 50px;
  font-size: 14px;
  list-style: none;
  text-align: left;
  display: flex;
  align-items: center;
  justify-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    left: 0px;
    top: 0px;
    position: absolute;
  }

  .label {
    margin-top: 2px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .user-big {
    display: flex;
    flex-direction: column;
    line-height: 18px;
  }
}
.content-big {
  display: flex;
  height: 100%;
  .content-left {
    width: 410px;
    background: #fff;
    border-right: 1px solid #eee;
    .title {
      background: #f5f5f5;
      color: #2f333c;
      font-weight: 700;
      padding: 12px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

  }
  .content-right {
    flex: 1;
    .table-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 60px;
      .table-right {
        display: flex;
       ::v-deep .el-input__inner {
          height: 32px;
          line-height: 32px;
        }
      }
    }
  }
}
::v-deep .el-dialog__body {
  overflow-y: auto;
  height: 600px;
  padding: 20px;
}
.title-tips {
  height: 40px;
  display: flex;
  align-items: center;
  background-color: #f0f7ff;
  padding: 0px 10px;
  border: 1px solid #abceff;

  span {
    margin-left: 10px;
    color: #888;
  }
}

.el-checkbox-group {
  margin-top: 20px;

  .el-checkbox {
    margin-bottom: 12px;
    width: 150px;
  }
}
.title {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  span {
    color:#3370ff;
  }
}
.exclusion {
  margin: 12px 0px;
  padding: 12px 16px;
  border-radius: 2px;
  border: 1px solid #f0f0f0;
}
</style>
